package com.zf.bm.common.core.sys.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.zf.bm.common.core.base.service.BaseService;
import com.zf.bm.common.core.sys.dao.MenuDao;
import com.zf.bm.common.core.sys.entity.Menu;
import com.zf.bm.vo.DashBoardVo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@DS("master")
@CacheConfig(cacheNames = "menuCache")
@Transactional(readOnly = true)
public class MenuService extends BaseService<MenuDao, Menu> {

    public List<Menu> findByParentIdsLike(Menu menu) {
        return baseMapper.findByParentIdsLike(menu);
    }

    public List<Menu> findByUserId(Menu menu) {
        return baseMapper.findByUserId(menu);
    }

    public int updateParentIds(Menu menu) {
        return baseMapper.updateParentIds(menu);
    }

    public int updateSort(Menu menu) {
        return baseMapper.updateSort(menu);
    }


    public List<Map<String,Integer>> queryByRoleId(Long id) {
        return baseMapper.queryByRoleId(id);
    }
    public int delete(Menu menu){
        return baseMapper.delete(menu);
    }

    public List<DashBoardVo> listForDashBord(){
        return baseMapper.listForDashBord();
    }

    public int updateSortOrIsShow(Menu menu) {
        return baseMapper.updateSortOrIsShow(menu);
    }
}
